<template>
  <el-row :gutter="16">
    <el-col :span="8">
      <div class="statistic-card">
        <el-statistic :value="dash_data.daily">
          <template #title>
            <div style="display: inline-flex; align-items: center">
              日活
              <el-tooltip effect="dark" content="每天活跃用户" placement="top">
                <el-icon style="margin-left: 4px" :size="12">
                  <Warning />
                </el-icon>
              </el-tooltip>
            </div>
          </template>
        </el-statistic>
        <!-- <div class="statistic-footer">
          <div class="footer-item">
            <span>than yesterday</span>
            <span class="green">
              24%
              <el-icon>
                <CaretTop />
              </el-icon>
            </span>
          </div>
        </div> -->
      </div>
    </el-col>
    <el-col :span="8">
      <div class="statistic-card">
        <el-statistic :value="dash_data.monthly">
          <template #title>
            <div style="display: inline-flex; align-items: center">
              月活
              <el-tooltip
                effect="dark"
                content="月度活跃用户数"
                placement="top"
              >
                <el-icon style="margin-left: 4px" :size="12">
                  <Warning />
                </el-icon>
              </el-tooltip>
            </div>
          </template>
        </el-statistic>
        <!-- <div class="statistic-footer">
          <div class="footer-item">
            <span>month on month</span>
            <span class="red">
              12%
              <el-icon>
                <CaretBottom />
              </el-icon>
            </span>
          </div>
        </div> -->
      </div>
    </el-col>
    <el-col :span="8">
      <div class="statistic-card">
        <el-statistic :value="dash_data.invite" title="New transactions today">
          <template #title>
            <div style="display: inline-flex; align-items: center">
              今天邀请人数
            </div>
          </template>
        </el-statistic>
        <!-- <div class="statistic-footer">
          <div class="footer-item">
            <span>than yesterday</span>
            <span class="green">
              16%
              <el-icon>
                <CaretTop />
              </el-icon>
            </span>
          </div>
          <div class="footer-item">
            <el-icon :size="14">
              <ArrowRight />
            </el-icon>
          </div>
        </div> -->
      </div>
    </el-col>
  </el-row>
</template>

<script lang="ts" setup>
import { loadDashboard } from "@/api/user";
import { Warning } from "@element-plus/icons-vue";
import { onMounted, ref } from "vue";

//

interface DashData {
  daily: number;
  monthly: number;
  invite: number;
}

const dash_data = ref<DashData>({
  daily: 0,
  monthly: 0,
  invite: 0
});
onMounted(() => {
  loadDashboard().then((res: any) => {
    console.log("mounted", res);
    if (res.code === 200) {
      dash_data.value = res.data;
      // tableData.value = res.data.records.reverse();
      // total_count.value = res.data.total_count;
    }
  });
});
</script>

<style scoped>
:global(h2#card-usage ~ .example .example-showcase) {
  background-color: var(--el-fill-color) !important;
}

.el-statistic {
  --el-statistic-content-font-size: 28px;
}

.statistic-card {
  height: 100%;
  padding: 20px;
  border-radius: 4px;
  background-color: var(--el-bg-color-overlay);
}

.statistic-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--el-text-color-regular);
  margin-top: 16px;
}

.statistic-footer .footer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.statistic-footer .footer-item span:last-child {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.green {
  color: var(--el-color-success);
}

.red {
  color: var(--el-color-error);
}
</style>
